<template>
	<view class="container">
		 <view class="img_container" >
			  <u-image :showLoading="true" :src="src" :fade="true" duration="450" width="150px" height="131px" ></u-image>
		 </view>
		 <view style="margin-top:20px;" >
			 <u-button type="success" :loading="loading" text="一键登录" @click="login" ></u-button>
		 </view>
	</view>
</template>
  
<script>
	import { Request , IMG_SERVER } from '@/utils/request.js';
	import {User} from "@/utils/user.js";
	import {Toast} from "@/utils/common.js";
	export default{
		data(){
			return {
				loading:false,
				src:IMG_SERVER + "/images/wechat.png",
			};
		},
		onload(){},
		methods: {
			login(){
				Toast.loadingT("登录中...");
				User.login().then((res)=>{
					Toast.loadingT("正在跳转...");
					//登录成功，跳转回首页
					uni.navigateBack({
						url:"/pages/index/index",
						fail() {
							uni.redirectTo({
								url:"/pages/index/index"
							})
						}
					})
				});
			}
		},
	};
</script>

<style>
	.container {
		margin: 80px 20px 20px 20px;
		text-align: center;
	}
	.img_container{
		 display: flex;    /*设置显示样式**/
		 align-items: center;    /**子view垂直居中*/
		 vertical-align: center; /**垂直居中*/
		 justify-content: center; /**内容居中*/
		 flex-direction:row; /**子view排列方式row--水平 column--垂直**/
	}
</style>